<project name="ProjectBuild" default="create_jar" basedir=".">

	<target name="check-properties-file">
		<property name="sdk" value="s40"/>
		<available file="${sdk}.build.properties" property="build.properties.present"/>
		<property file="${sdk}.build.properties" />
	</target>
	
	<target name="init" description="Initializes all dependencies and classpath" depends="check-properties-file" if="build.properties.present">
		<echo message="Loading properties from ${sdk}.build.properties" />
	
	    <path id="javac.bootcp">
			<fileset dir="${dir.lib.3rdparty}" includes="**/*.jar"/>
			<fileset dir="${dir.lib.sdk}" includes="**/*.jar"/>
		</path>
		
		<taskdef classpath="${lib.antenna}" resource="antenna.properties" />		
		<taskdef classpath="${lib.antcontrib}" resource="net/sf/antcontrib/antcontrib.properties" />		
		<taskdef name="floggy-persistence-weaver" classname="net.sourceforge.floggy.persistence.WeaverTask" classpathref="javac.bootcp" />		
	</target>

	<target name="clean" description="Cleans the files created by the build process" if="build.properties.present" depends="init">
		<delete dir="${dir.tmp}" />	
		<delete dir="${dir.bin}" />
		<mkdir dir="${dir.tmp}" />
    	<mkdir dir="${dir.bin}" />
	</target>

	<target name="preprocess" if="build.properties.present" depends="clean"> 
        <wtkpreprocess 
        	srcdir="${dir.src}" 
        	destdir="${dir.tmp.pre}" 
        	symbols="${preprocessing.symbols}" 
        	printsymbols="true">
		</wtkpreprocess>
	</target>

	<target name="build" if="build.properties.present" depends="preprocess">
    	<wtkbuild
            srcdir="${dir.tmp.pre}"
            destdir="${dir.tmp.classes}"
            preverify="true"
            bootclasspathref="javac.bootcp"    		
            source="1.3"
    		includeantruntime="false">
		</wtkbuild>
	</target>
	
	<target name="floggy" if="build.properties.present" depends="build">
	
		<copy todir="${dir.tmp.floggy}">
			<fileset dir="${dir.res}"/>		  
		</copy>
	
		<floggy-persistence-weaver 
			bootclasspathref="javac.bootcp" 
			input="${dir.tmp.classes}" 
			output="${dir.tmp.floggy}" />
	</target>

	<target name="create_jar" depends="floggy">
		<property name="jar_name" value="${dir.bin}/${project.jar.name}.jar"/>
    	<jar destfile="${dir.bin}/${project.jar.name}.jar" basedir="${dir.tmp.floggy}" />
  	</target>
</project>